package top.iridescent.entity.model.res;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ChuTuLvModel implements Serializable {

    private int allCounts = 0;
    private int tuCounts = 0;
    private Long times=0l;
    private Long roleId;
    private String roleName;
    private int roleLevel;
    private List<ChuTuLvModel> children;

    private Double chuTuLv = 0D;


    public void add(int total,int wo,Long time){
        this.allCounts=this.allCounts+total;
        this.tuCounts=this.tuCounts+wo;
        this.times=this.times+time;
        BigDecimal allB=new BigDecimal(allCounts);
        BigDecimal woB=new BigDecimal(tuCounts);
        BigDecimal gaiLvB=woB.divide(allB,4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)).setScale(2);
        chuTuLv=gaiLvB.doubleValue();
    }


}
